//
//  BaseNavController.swift
//  WFCommunity
//
//  Created by 白翊 on 2020/10/20.
//  Copyright © 2020 白翊. All rights reserved.
//

import UIKit

class BaseNavController: UINavigationController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.navigationBar.isTranslucent = false
        
        if #available(iOS 13.0, *) {
            let apperance = UINavigationBarAppearance()
            apperance.backgroundEffect = UIBlurEffect(style: .regular)
            apperance.shadowColor = .line
            apperance.backgroundColor = .bg
            apperance.titleTextAttributes = [
                .foregroundColor : UIColor.title,
                .font : UIFont.systemFont(ofSize: 16, weight: .medium)
            ]
            navigationBar.standardAppearance = apperance
            navigationBar.scrollEdgeAppearance = apperance
        } else {
            navigationBar.titleTextAttributes = [
                .foregroundColor : UIColor.title,
                .font : UIFont.systemFont(ofSize: 16, weight: .medium)
            ]
            navigationBar.barTintColor = .bg
            navigationBar.shadowImage = UIImage()
            navigationBar.setBackgroundImage(UIImage(color: .bg), for: .default)
        }
    }
        
}

extension BaseNavController {
    
    override var preferredStatusBarStyle: UIStatusBarStyle {
        if #available(iOS 13.0, *) {
            return UIColor.darkMode ? .darkContent : .lightContent
        } else {
            return .default
        }
    }
}
